<jsp:directive.page contentType="text/html;charset=utf-8" />
<%@ include file="/taglibs.jsp" %>

<head>
<title>Setup - Products</title>

<script type="text/javascript">
$(function() {
	$("#new" ).button();
	$("#new").click(function(){window.location='${ctx}/product!editNew.action';});
});
$(document).ready(function(){
	jQuery("#list").jqGrid( {
		url : 'product!jsonList.action',
		//search : {sopt : ['eq','ne']},
		jsonReader : {
			root : "rows", repeatitems : false, id : "0"},
		colNames : [ '<s:text name="module.common.id"/>',
					 '<s:text name="module.product.productCode"/>', 
		 			 '<s:text name="module.product.primaryProductCatalog"/>', 
		 			 '<s:text name="module.product.internalName"/>',
		 			 '<s:text name="module.common.description"/>'],
		colModel : [ {name : 'id',index : 'id', width : 20, hidden:true}, 
					 {name : 'productCode',index : 'productCode', width : 120},
		     		 {name : 'primaryProductCatalog.catalogName',index : 'primaryProductCatalog.catalogName',width : 120},
		     		 {name : 'internalName',sortable : false,width : 150,
		     			formatter:'showlink',formatoptions:{baseLinkUrl:'product!view.action',idName:'product.id'}},
		     		 {name : 'description',sortable : false, width : 250}],		
		rowNum : 15,
		rowList : [15,30,50],
		height: 'auto',
		pager : '#pager',
		sortname : 'productName',
		viewrecords: true,
		sortorder : 'asc',
		loadOnce : true,
		caption : "",
		multiselect : true,
		editurl : 'product!jqgridOper.action',
		onSelectRow: function(ids) {
			if(ids == null) {
				alert();
			}
			//window.location='product!view.action?product.id='+ids;
		}
	});
	jQuery("#list").jqGrid('navGrid',"#pager",{edit:false,add:false,del:true,search:false,refresh:false},
			{reloadAfterSubmit:false}, // edit options
			{reloadAfterSubmit:false}, // add options
			{reloadAfterSubmit:false}, // del options
			{sField : "jq.searchField", sFilter : "jq.searchFilter", sOper : "jq.searchOper", sValue : "jq.searchString"});//search options
	jQuery("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
	// add custom button to export the data to excel
	jQuery('#list').jqGrid('navButtonAdd','#pager',{id:'pager_excel', caption:'',title:'Export To Excel',onClickButton : function(e)
		{jQuery("#list").jqGrid('excelExport',{tag:'excel', url:'product!export.action'});},buttonicon:'ui-icon-arrowthickstop-1-s'});
});


</script>
</head>


<body>

<div class="page-header">
<h2><s:text name="module.product"/> : <s:text name="module.product.allProducts"/></h2>
</div>
<button id="new" class="btn btn-primary"><s:text name="module.product.newProduct"/></button>

<div>
<table id="list"></table>
<div id="pager"></div>
</div>

<%--
<iframe src="http://localhost:8080/roller/iobike" id="iframepage" name="iframepage" frameBorder=0 scrolling=no width="100%" onLoad="iFrameHeight()" ></iframe>
 --%>
 
</body>
